#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

int arr[100005];
int n;

int main(){
    cin>>n;
    for(int i=1; i<=n; ++i){
        scanf("%d", arr+i);
        arr[i]+=arr[i-1]; 
    }
    int left, right;
    while(cin>>left>>right){
        cout<<arr[right+1]-arr[left]<<endl;
    }
}